#!/bin/sh
basepath=$(cd `dirname $0`; pwd)
LOG_FILE="$basepath/log/shell.log"
CONFIG_FILE="$basepath/conf/config.properties"
HIVE_TABLE="log_user"
exec &>>${LOG_FILE}
function log()
{
	local curtime=`date "+%Y-%m-%d %H:%M:%S"`
	echo "$curtime $*">> ${LOG_FILE}
}
user=`whoami`
log "System.user:$user"
if [ "$user" != "hdfs" ]; then
log "ERROR:user is $user,please trans user to hdfs!!!"
exit 1
fi
rootdir=`sed -n '/root.dir/{s/.*=//;p}' $CONFIG_FILE`
echo $rootdir
yesterday=`date -d -1days '+%Y-%m-%d'`
log "Loading log to hive table:${HIVE_TABLE}"
`hive -e "alter table ${HIVE_TABLE} add partition(day='$yesterday') location '$yesterday';"`
